package o;

import android.content.Context;
import android.content.pm.PackageInfo;
import androidx.annotation.Nullable;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class cpo {
    @Nullable
    public File ॱ(Context context) {
        return context.getExternalFilesDir("");
    }

    public boolean ˊ(Context context, File file, File file2) {
        boolean z;
        if (file.renameTo(file2)) {
            z = false;
        } else if (ˎ(file, file2)) {
            z = true;
        } else {
            cnu.ˏ.ˊ("BackupFilePathProcess", "can not copy the file to new Path");
            return false;
        }
        PackageInfo packageArchiveInfo = context.getPackageManager().getPackageArchiveInfo(file2.getAbsolutePath(), 0);
        if (!(packageArchiveInfo == null || cop.ˊ == null)) {
            cop.ˊ.ˊ(3, packageArchiveInfo.packageName);
        }
        if (z && !file.delete()) {
            cnu.ˏ.ˊ("BackupFilePathProcess", "can not delete old file");
        }
        return true;
    }

    private boolean ˎ(File file, File file2) {
        InputStream fileInputStream;
        try {
            fileInputStream = new FileInputStream(file);
            boolean ॱ = ॱ(fileInputStream, file2);
            fileInputStream.close();
            return ॱ;
        } catch (IOException e) {
            return false;
        } catch (Throwable th) {
            fileInputStream.close();
        }
    }

    private boolean ॱ(java.io.InputStream r9, java.io.File r10) {
        /* JADX: method processing error */
/*
Error: jadx.core.utils.exceptions.JadxRuntimeException: Exception block dominator not found, method:o.cpo.ॱ(java.io.InputStream, java.io.File):boolean. bs: [B:16:0x002c, B:30:0x0042]
	at jadx.core.dex.visitors.regions.ProcessTryCatchRegions.searchTryCatchDominators(ProcessTryCatchRegions.java:86)
	at jadx.core.dex.visitors.regions.ProcessTryCatchRegions.process(ProcessTryCatchRegions.java:45)
	at jadx.core.dex.visitors.regions.RegionMakerVisitor.postProcessRegions(RegionMakerVisitor.java:63)
	at jadx.core.dex.visitors.regions.RegionMakerVisitor.visit(RegionMakerVisitor.java:58)
	at jadx.core.dex.visitors.DepthTraversal.visit(DepthTraversal.java:31)
	at jadx.core.dex.visitors.DepthTraversal.visit(DepthTraversal.java:17)
	at jadx.core.ProcessClass.process(ProcessClass.java:37)
	at jadx.api.JadxDecompiler.processClass(JadxDecompiler.java:306)
	at jadx.api.JavaClass.decompile(JavaClass.java:62)
*/
        /*
        r8 = this;
        r0 = 0;
        r3 = 0;
        r1 = r10.exists();	 Catch:{ IOException -> 0x003a, all -> 0x00c4 }
        if (r1 == 0) goto L_0x0017;	 Catch:{ IOException -> 0x003a, all -> 0x00c4 }
    L_0x0008:
        r1 = r10.delete();	 Catch:{ IOException -> 0x003a, all -> 0x00c4 }
        if (r1 != 0) goto L_0x0017;	 Catch:{ IOException -> 0x003a, all -> 0x00c4 }
    L_0x000e:
        r1 = o.cnu.ˏ;	 Catch:{ IOException -> 0x003a, all -> 0x00c4 }
        r2 = "BackupFilePathProcess";	 Catch:{ IOException -> 0x003a, all -> 0x00c4 }
        r4 = "destFile delete error.";	 Catch:{ IOException -> 0x003a, all -> 0x00c4 }
        r1.ˏ(r2, r4);	 Catch:{ IOException -> 0x003a, all -> 0x00c4 }
    L_0x0017:
        r4 = new java.io.FileOutputStream;	 Catch:{ IOException -> 0x003a, all -> 0x00c4 }
        r4.<init>(r10);	 Catch:{ IOException -> 0x003a, all -> 0x00c4 }
        r1 = 4096; // 0x1000 float:5.74E-42 double:2.0237E-320;
        r1 = new byte[r1];	 Catch:{ all -> 0x002b }
    L_0x0020:
        r2 = r9.read(r1);	 Catch:{ all -> 0x002b }
        if (r2 < 0) goto L_0x0042;	 Catch:{ all -> 0x002b }
    L_0x0026:
        r5 = 0;	 Catch:{ all -> 0x002b }
        r4.write(r1, r5, r2);	 Catch:{ all -> 0x002b }
        goto L_0x0020;
    L_0x002b:
        r1 = move-exception;
        r4.flush();	 Catch:{ IOException -> 0x008d, all -> 0x007b }
    L_0x002f:
        r2 = r4.getFD();	 Catch:{ IOException -> 0x0098, all -> 0x007b }
        r2.sync();	 Catch:{ IOException -> 0x0098, all -> 0x007b }
    L_0x0036:
        r4.close();	 Catch:{ IOException -> 0x00a3, all -> 0x007b }
    L_0x0039:
        throw r1;	 Catch:{ IOException -> 0x003a, all -> 0x00c4 }
    L_0x003a:
        r1 = move-exception;
        r1 = r3;
    L_0x003c:
        if (r1 == 0) goto L_0x0041;
    L_0x003e:
        r1.close();	 Catch:{ IOException -> 0x00ae }
    L_0x0041:
        return r0;
    L_0x0042:
        r4.flush();	 Catch:{ IOException -> 0x0062, all -> 0x007b }
    L_0x0045:
        r1 = r4.getFD();	 Catch:{ IOException -> 0x0070, all -> 0x007b }
        r1.sync();	 Catch:{ IOException -> 0x0070, all -> 0x007b }
    L_0x004c:
        r4.close();	 Catch:{ IOException -> 0x0082, all -> 0x007b }
    L_0x004f:
        r1 = 0;
        r0 = 1;
        if (r3 == 0) goto L_0x0041;
    L_0x0053:
        r1.close();	 Catch:{ IOException -> 0x0057 }
        goto L_0x0041;
    L_0x0057:
        r1 = move-exception;
        r2 = o.cnu.ˏ;
        r3 = "BackupFilePathProcess";
        r4 = "";
        r2.ˊ(r3, r4, r1);
        goto L_0x0041;
    L_0x0062:
        r1 = move-exception;
        r2 = o.cnu.ˏ;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r5 = "BackupFilePathProcess";	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r6 = "";	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r2.ˊ(r5, r6, r1);	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        goto L_0x0045;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
    L_0x006d:
        r1 = move-exception;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r1 = r4;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        goto L_0x003c;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
    L_0x0070:
        r1 = move-exception;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r2 = o.cnu.ˏ;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r5 = "BackupFilePathProcess";	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r6 = "";	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r2.ˊ(r5, r6, r1);	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        goto L_0x004c;
    L_0x007b:
        r0 = move-exception;
    L_0x007c:
        if (r4 == 0) goto L_0x0081;
    L_0x007e:
        r4.close();	 Catch:{ IOException -> 0x00b9 }
    L_0x0081:
        throw r0;
    L_0x0082:
        r1 = move-exception;
        r2 = o.cnu.ˏ;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r5 = "BackupFilePathProcess";	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r6 = "";	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r2.ˊ(r5, r6, r1);	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        goto L_0x004f;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
    L_0x008d:
        r2 = move-exception;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r5 = o.cnu.ˏ;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r6 = "BackupFilePathProcess";	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r7 = "";	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r5.ˊ(r6, r7, r2);	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        goto L_0x002f;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
    L_0x0098:
        r2 = move-exception;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r5 = o.cnu.ˏ;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r6 = "BackupFilePathProcess";	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r7 = "";	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r5.ˊ(r6, r7, r2);	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        goto L_0x0036;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
    L_0x00a3:
        r2 = move-exception;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r5 = o.cnu.ˏ;	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r6 = "BackupFilePathProcess";	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r7 = "";	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        r5.ˊ(r6, r7, r2);	 Catch:{ IOException -> 0x006d, all -> 0x007b }
        goto L_0x0039;
    L_0x00ae:
        r1 = move-exception;
        r2 = o.cnu.ˏ;
        r3 = "BackupFilePathProcess";
        r4 = "";
        r2.ˊ(r3, r4, r1);
        goto L_0x0041;
    L_0x00b9:
        r1 = move-exception;
        r2 = o.cnu.ˏ;
        r3 = "BackupFilePathProcess";
        r4 = "";
        r2.ˊ(r3, r4, r1);
        goto L_0x0081;
    L_0x00c4:
        r0 = move-exception;
        r4 = r3;
        goto L_0x007c;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.cpo.ॱ(java.io.InputStream, java.io.File):boolean");
    }
}
